package com.bawei.auth.controller;

import com.bawei.auth.service.SysUserService;
import com.bawei.common.core.domain.R;
import com.bawei.common.security.service.TokenService;
import com.bawei.mall.user.domain.CusUser;
import com.bawei.system.domain.model.LoginUser;
import org.apache.catalina.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/sso")
public class LoginController {
    @Autowired
    private TokenService tokenService;

    @Autowired
    private SysUserService sysUserService;


    @GetMapping("/login")
    public R<?> login(@RequestParam("username") String username,@RequestParam("password") String password){
        LoginUser dologin = sysUserService.login(username,password);
        Map<String, Object> token2 = tokenService.createToken2(dologin);
        return R.ok(token2);
    }

    @GetMapping("/info")
    public R<CusUser> getInfo(){
        R<CusUser> info = sysUserService.getInfo();
        return info;
    }

}
